home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
rjs.lha
/
RJS
/
Transport
/
tests
/
xq.C
< prev
Wrap
C/C++ Source or Header
|
1991-06-14
|
2KB
|
87 lines
#include <iostream.h>
#include <stdio.h>
#include <osfcn.h>
#include <libc.h>
#include "RJS/Transport.h"
#include "RJS/Convert.h"
typedef struct {
char object;
char operation;
char buffer[512];
} request;
typedef struct {
char status;
char eod;
char buffer[512];
} reply;
void test(char *name, char *obj)
{
char buffer[512];
unsigned short len;
request rq;
reply rp;
RJS_DECnetAddress server_address(name,RJS_Convert::toInt(obj));
RJS_DECnetSeqPacket server;
// cout << server_address.ss_message() << endl;
server.active(server_address);
server.linger();
rq.object=1;
rq.operation=1;
server.write((char *) &rq,2);
while ( 1) {
server.read((char *)&rp,sizeof(rp));
if (rp.eod) break;
char *p=rp.buffer,*t;
char queue_name[32];
unsigned short num_jobs;
char qstatus[128];
t=queue_name;
while (*p) *t++=*p++;
*t++ = 0;
p++;
num_jobs = (unsigned short) *p;
p += 2;
t=qstatus;
while (*p) *t++=*p++;
*t++ = 0;
cout << "client: read ==> '" << queue_name << "' '"
<< num_jobs << "' '" << qstatus << "'" <<endl;
}
rq.object=2;
rq.operation=1;
server.write((char *) &rq,2);
server.read(buffer,5);
cout << "client: read ==> '" << buffer << "'" << endl;
rq.object=0;
rq.operation=0;
server.write((char *) &rq,2);
// while ( server.read(buffer,512)>0) {
// cout << "client: read ==> '" << buffer << "'" << endl;
// }
}
int main(int argc, char *argv[])
{
if (argc!=3) {
cout<< "usage: " << argv[0] << "host object " << endl;
exit(1);
}
test(argv[1],argv[2]);
exit(0);
}